package com.itheima.stock.xxljob;

import com.itheima.stock.service.StockTimerService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 定义股票相关数据的定时任务
 */
@Component
public class StockJob {
    private static Logger logger = LoggerFactory.getLogger(StockJob.class);

    @Autowired
    private StockTimerService stockTimerService;

    @XxlJob("testStock")
    public void jobTest(){
        System.out.println(System.currentTimeMillis()+"执行。。。。。");
    }

    public void init(){
        logger.info("init");
    }

    public void destroy(){
        logger.info("destory");
    }

    /**
     * 每周1到周5，上午九点半到11点半，下午1点到3点的流水数据
     * 定义每分钟获取一次国内大盘数据
     */
    @XxlJob("stock_inner_market")
    public void getStockAMarketTask(){
        stockTimerService.getInnerMarketInfo();
    }

    /**
     * 定时采集A股数据
     */
    @XxlJob("getStockInfos")
    public void getStockInfos(){
        stockTimerService.getStockRtIndex();
    }

    /**
     * 定时采集板块数据
     */
    @XxlJob("getStockBlockInfoTask")
    public void getStockBlockInfoTask(){
        stockTimerService.getStockSectorRtIndex();
    }
}
